<template>
	<view class="container">
		<form @submit="formSubmit">
			<view class="cu-form-group border-b">
				<view class="title">旧密码</view>
				<view class="text"><input type="password" name="OldPwd" placeholder="请输入旧密码" value=""></input></view>
			</view>
			<view class="cu-form-group border-b">
				<view class="title">新密码</view>
				<view class="text"><input type="password" name="NewPwd" placeholder="请输入新密码" value=""></input></view>
			</view>
			<view class="cu-form-group border-b">
				<view class="title">确认密码</view>
				<view class="text"><input type="password" name="SurePwd" placeholder="请输入确认密码" value=""></input></view>
			</view>
			<view class="btn">
				<button class="publishs" form-type="submit">确认修改</button>
			</view>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			}
		},
		onShow() {
			
		},
		onLoad(options) {

		},
		methods: {			
			formSubmit(e){
				var data = e.detail.value;
				data.Act="Update_Pwd";
				if (data.OldPwd.Trim() == "") {
					this.Util.Toast('旧密码不能为空');
					return false;
				}
				if (data.OldPwd.length < 1 || data.OldPwd.length > 18) {
					this.Util.Toast('旧密码长度必须在1-18位之间');
					return false;
				}
				if (data.NewPwd.Trim() == "") {
					this.Util.Toast('新密码不能为空');
					return false;
				}
				if (data.NewPwd.length < 1 || data.NewPwd.length > 18) {
					this.Util.Toast('新密码长度必须在1-18位之间');
					return false;
				}
				if (data.SurePwd.Trim() == "") {
					this.Util.Toast('确认密码不能为空');
					return false;
				}
				if (data.SurePwd.length < 1 || data.SurePwd.length > 18) {
					this.Util.Toast('确认密码长度必须在1-18位之间');
					return false;
				}
				if (data.NewPwd!=data.SurePwd) {
					this.Util.Toast('2次密码输入不一致');
					return false;
				}
				this.Util.Loading("请稍候...");
				this.Util.Post(data, json=>{
					uni.stopPullDownRefresh();
					this.Util.HideLoading();
					if(json.State){
						this.Util.Toast(json.Msg,()=>{
							uni.navigateBack({
								delta:1
							})
						})
					}else{
						this.Util.Alert(json.Msg);
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.container{padding-top:30rpx;}
</style>
